#include "Light.h"
#include "D3DObj.h"
#include <assert.h>

Light::Light()
{
	m_ID = 0;
	SetID();

	m_IsOn = true;

	m_Type = 1;

	m_Position = D3DXVECTOR3(0.0f, 0.0f, 0.0f);

	m_Ambient = g_White / 5.0f;

	m_Diffuse = g_White;
	
	m_Direction.x = 1.0f;
	m_Direction.y = -1.0f;
	m_Direction.z = 1.0f;
	
	//Atten = 1 / (att0 + att1 * d + att2 * d2)
	m_Attenuation0 = 0.0f;    // no constant inverse attenuation
	m_Attenuation1 = 0.125f;    // only .125 inverse attenuation
	m_Attenuation2 = 0.0f;    // no square inverse attenuation

	m_Range = 100.0f;
}

Light::~Light()
{

}

// called with constructor to make sure the ID is valid
// verifies the value is greater or equal to the next valid ID
void Light::SetID()
{	
	static unsigned int NxId = 0;
	//increment id
	NxId++;

	//make sure the val is equal to or greater than the next available ID
	assert ((m_ID < NxId) && "<Light::SetId>: Invalid ID");

	m_ID = NxId;
}


void Light::Init(int type, const Colour &colour, const Vec3 &Direction, const Vec3 &Position)
{
	m_Type = type;
	//set the ambient to half the diffuse colour
	m_Ambient = colour / 5.0f;
	m_Diffuse = colour;
	
	m_Direction = Direction;
	m_Position = Position;
}

void Light::Set()
{

}

void Light::Use()
{
	if(m_IsOn)
	{

	}
}

void Light::Enable()
{
	m_IsOn = true;
}

void Light::Disable()
{
	m_IsOn = false;
}

void Light::Draw()
{

}